package com.niiuzu.client.screen.feed;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Implémentation de la vue pour la gestion des flux et des données RSS.
 */
public class FeedViewImpl extends Composite implements FeedView {

	/**
	 * Interface {@link UiBinder} adaptée à la vue {@link FeedViewImpl}.
	 */
	interface SuitedUiBinder extends UiBinder<Widget, FeedViewImpl> {

	}

	@UiField
	SimplePanel channelFilterContainer;
	@UiField
	SimplePanel feedActionsContainer;
	@UiField
	SimplePanel feedViewerContainer;
	@UiField
	PushButton refreshButton;
	@UiField
	Widget refreshMessage;

	@Override
	public void createView() {
		SuitedUiBinder uiBinder = GWT.create(SuitedUiBinder.class);
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void disableActionComponents() {
		refreshButton.setEnabled(false);
	}

	@Override
	public void enableActionComponents() {
		refreshButton.setEnabled(true);
	}

	@Override
	public HasClickHandlers getRefreshHasClickHandlers() {
		return refreshButton;
	}

	@Override
	public void hideRefreshMessage() {
		refreshMessage.setVisible(false);
	}

	@Override
	public void showRefreshMessage() {
		refreshMessage.setVisible(true);
	}

	@Override
	public void setChannelFilterView(IsWidget channelFilterView) {
		channelFilterContainer.setWidget(channelFilterView);
	}

	@Override
	public void setFeedActionsView(IsWidget feedActionsView) {
		feedActionsContainer.setWidget(feedActionsView);
	}

	@Override
	public void setFeedViewerView(IsWidget feedViewerView) {
		feedViewerContainer.setWidget(feedViewerView);
	}
}
